package test;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: gc
 * @Date: 2024/7/16 14:48
 * @explain:
 **/
public class mapToMarkdown {
    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        map.put("Key1", "Value1");
        map.put("Key2", "Value2");
        map.put("Key3", "Value3");

        Map<String, String> testMap = new HashMap<>();
        testMap.put("Name", "John Doe");
        testMap.put("Age", "30");
        String markdownText = convertMapToMarkdown(testMap);
        System.out.println(markdownText);
        String markdownString = mapToMarkdown(map);
        System.out.println(markdownString);
    }

    public static String mapToMarkdown(Map<String, String> map) {
        StringBuilder markdownBuilder = new StringBuilder();

        for (Map.Entry<String, String> entry : map.entrySet()) {
            markdownBuilder.append("##### "+entry.getKey() + ": ");
            markdownBuilder.append(entry.getValue() + "\n");
        }
        return markdownBuilder.toString();
    }


    public static String convertMapToMarkdown(Map<String, String> map) {
        StringBuilder markdownBuilder = new StringBuilder();
        for (Map.Entry<String, String> entry : map.entrySet()) {
            String key = entry.getKey();
            String value = entry.getValue();
            // 假设你想设置所有值的字体大小为24px
            String markdownValue = "<font color='#FF0000' size='4'>" + value + "</span>";
            markdownBuilder.append("**").append(key).append("**: ").append(markdownValue).append("\n");
        }
        return markdownBuilder.toString();
    }
}
